use std::fmt;

pub type XcontainerResult<T> = Result<T,XcontainerError>;

#[derive(Debug)]
pub enum XcontainerError {
    FullContainer,
    XcontainerWriteManager(std::io::Error),
    XcontainerReadManager(std::io::Error),
    XcontainerMetaFile(std::io::Error),
    XcontainerPoolFile(std::io::Error),
    XcontainerMetaLen(std::io::Error),
    FixedContainerRead(std::io::Error),
    FixedContainerWrite(std::io::Error),
    DynContainerSeek(std::io::Error),
    DynContainerRead(std::io::Error),
    DynContainerWrite(std::io::Error),
}

impl fmt::Display for XcontainerError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::FullContainer => write!(f,"Error container is full"),
            Self::XcontainerWriteManager(e) => write!(f,"Error xcontainer write manager create error:{}",e),
            Self::XcontainerReadManager(e) => write!(f,"Error xcontainer read manager create error:{}",e),
            Self::XcontainerMetaFile(e) => write!(f,"Error xcontainer meta file open error:{}",e),
            Self::XcontainerMetaLen(e) => write!(f,"Error xcontainer meta file size error:{}",e),
            Self::XcontainerPoolFile(e) => write!(f,"Error xcontainer pool file open error:{}",e),
            Self::DynContainerSeek(e) => write!(f,"Error dyn ontainer seek error:{}",e),
            Self::DynContainerRead(e) => write!(f,"Error dyn ontainer read error:{}",e),
            Self::DynContainerWrite(e) => write!(f,"Error dyn ontainer write error:{}",e),
            Self::FixedContainerRead(e) => write!(f,"Error fixed ontainer read error:{}",e),
            Self::FixedContainerWrite(e) => write!(f,"Error fixed ontainer write error:{}",e),
        }
    }
}